package com.fortune.controller;

import com.faneui.common.exception.BusinessException;
import com.fortune.dal.dao.FundInfoDAO;
import com.fortune.dal.model.FundInfo;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("fundinfo")
public class FundInfoController extends AbstractController {

    @Autowired
    private FundInfoDAO fundInfoDAO;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws BusinessException {
        ModelAndView mv = new ModelAndView("fundinfo");
        mv.addObject("menuFlag", "fundinfo");
        return mv;
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public List<FundInfo> list(@ModelAttribute FundInfo fundInfo) throws BusinessException {
        List<FundInfo> list = null;
        try {
            list = fundInfoDAO.queryByModel(fundInfo) ;
        }catch (Exception ex) {
            logger.error("",ex);
            return Lists.newArrayList() ;
        }
        return list;
    }


}
